<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title></title>
    <!--标准mui.css-->
    <link rel="stylesheet" href="css/mui.min.css">
    <!--App自定义的css-->
    <link rel="stylesheet" type="text/css" href="css/app.css"/>
    <link href="css/mui.picker.css" rel="stylesheet"/>
    <link href="css/mui.poppicker.css" rel="stylesheet"/>
    <link href="css/word.css" rel="stylesheet"/>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
    <script src="js/jquery.touch-punch.min.js"></script>
    <script src="js/mui.min.js"></script>
    <script src="js/mui.picker.js"></script>
    <script src="js/mui.poppicker.js"></script>
    <script src="js/city.data.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/book.content.data.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/word.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/mix.data.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<nav class="mui-bar mui-bar-tab">
    <a class="mui-tab-item mui-active" href="#tabbar-index">
        <span class="mui-icon mui-icon-home"></span>
        <span class="mui-tab-label">首页</span>
    </a>
    <a class="mui-tab-item" href="#tabbar-settings">
        <span class="mui-icon mui-icon-gear"></span>
        <span class="mui-tab-label">设置</span>
    </a>
</nav>
<div class="mui-content">
    <div id="tabbar-index" class="mui-control-content mui-active">
        <div class="ui-alert">
            <span id="result"></span>
            <div class="mui-btn mui-btn-primary" id="refresh">开始</div>
        </div>
    </div>
    <div id="tabbar-settings" class="mui-control-content">
        <form class="mui-input-group">
            <div class="mui-input-row">
                <label>随机题数</label>
                <div class="mui-numbox">
                    <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
                    <input id="randomSentenceNum" class="mui-input-numbox" type="number" value="3"/>
                    <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
                </div>
            </div>
        </form>
        <button id='difficultyLevelPicker' class="mui-btn mui-btn-block" type='button'>挑战模式</button>
        <button id='showCityPicker' class="mui-btn mui-btn-block" type='button'>课程选择</button>
    </div>
</div>


<script>

    (function ($, doc) {
        $.init();
        $.ready(function () {

            //-----------------------------------------
            //挑战模式选择器
            var difficultyLevelPicker = new $.PopPicker({
                layer: 1
            });
            difficultyLevelPicker.setData([{
                value: '1',
                text: '简单'
            }, {
                value: '2',
                text: '中等'
            }, {
                value: '3',
                text: '困难'
            }, {
                value: '4',
                text: '全图'
            }
            ]);
            var difficultyLevelPickerButton = doc.getElementById('difficultyLevelPicker');
            difficultyLevelPickerButton.addEventListener('tap', function (event) {
                difficultyLevelPicker.show(function (items) {
                    AppConfig.setDifficultyLevel(items[0].value);
                    AppConfig.setDifficultyLabel(items[0].text)
                    //返回 false 可以阻止选择框的关闭
                    //return false;
                });
            }, false);

            //书本选择器
            var cityPicker = new $.PopPicker({
                layer: 2
            });
            cityPicker.setData(cityData);
            var showCityPickerButton = doc.getElementById('showCityPicker');
            showCityPickerButton.addEventListener('tap', function (event) {
                cityPicker.show(function (items) {
                    AppConfig.setBookContentId(items[1].value);
                    AppConfig.setBookContentLabel(items[0].text + " - " + items[1].text)
                    refresh();
                    //返回 false 可以阻止选择框的关闭
                    //return false;
                });
            }, false);

            const randomSentenceNumInput = document.getElementById("randomSentenceNum");
            randomSentenceNumInput.addEventListener('change', function () {
                AppConfig.setRandomSentenceNum(this.value);
            });

        });
    })(mui, document);

    $(document).ready(function () {
        $('#refresh').on('click', function () {
            refresh();
        });
        $('#refresh').click();
    })

</script>
</body>


</html>
